//
//  CollectionMovDetailViewController.m
//  LQH-Douban
//
//  Created by Chie Li on 15/10/27.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "CollectionMovDetailViewController.h"
#import "MovieDetailView.h"
#import "Movie.h"
@interface CollectionMovDetailViewController ()


@property (nonatomic, strong)MovieDetailView *movieDetailView;
@end

@implementation CollectionMovDetailViewController

- (void)loadView
{
    self.movieDetailView = [[MovieDetailView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    
    self.view = self.movieDetailView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    _movieDetailView.scrollView.frame = CGRectMake(0, 0, 375, 554);
    //    //滚动视图的偏移量
    _movieDetailView.scrollView.contentSize = CGSizeMake(375, 280+[self textHeight:_movieModel.actors]+50 +[self textHeight:_movieModel.plot_simple]);
    //演员信息自适应
    _movieDetailView.actorsLabel.frame = CGRectMake(10, 270, 355, 10 +[self textHeight:_movieModel.actors]);
    
    _movieDetailView.mLabel.frame = CGRectMake(30, 285+[self textHeight:_movieModel.actors], 333, 30);
    //电影情节自适应
    _movieDetailView.plot_simpleLabel.frame = CGRectMake(10, 320+[self textHeight:_movieModel.actors], 355, [self textHeight:_movieModel.plot_simple]);
    //
    
    
    _movieDetailView.titleLabel.text = _movieModel.title;
    _movieDetailView.ratingLabel.text = [NSString stringWithFormat:@"评分:%@   (%@评论)",_movieModel.rating, _movieModel.rating_count];
    
    _movieDetailView.runtimeLabel.text = _movieModel.runtime;
    _movieDetailView.genresLabel.text = _movieModel.genres;
    _movieDetailView.countryLabel.text = _movieModel.country;
    _movieDetailView.actorsLabel.text = _movieModel.actors;
    _movieDetailView.plot_simpleLabel.text = _movieModel.plot_simple;
    
    _movieDetailView.movieImageView.image = _movieModel.myImage;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

//计算文本高度
- (CGFloat)textHeight:(NSString *)str{
    CGRect newRect = [str boundingRectWithSize:CGSizeMake(355, 11111) options:NSStringDrawingUsesLineFragmentOrigin attributes: @{NSFontAttributeName : [UIFont systemFontOfSize:17]} context:nil];
    return newRect.size.height;
}

@end
